package de.schmitt.marc.msRetailManager;


import de.schmitt.marc.msRetailManager.api.Persistence;
import de.schmitt.marc.msRetailManager.api.Service;
import de.schmitt.marc.msRetailManager.gui.MainWindow;
import de.schmitt.marc.msRetailManager.persistence.DummyPersistence;
import de.schmitt.marc.msRetailManager.service.DummyService;
import java.io.OutputStream;
import java.io.PrintStream;

/**
 * Programm Entry Point
 * @author schmitt
 */
public class Starter {

    private static PrintStream log;
    private static Persistence persistence;
    private static Service service;
    private static MainWindow mainWindow;
    
    public Starter() {
        if(log == null) log = startupLogger();
        if(persistence == null) persistence = startupPersistence(log);
        if(service == null) service = startupService(persistence, log);
        if(mainWindow == null) mainWindow = startupGUI(service, log);
    }
        
    public static void main(String[] args) {
        new Starter();
    }

   
    private static PrintStream startupLogger() {
        PrintStream ret =  System.out;
        ret.print("Grundsystem wird gestartet...");
        ret.print("[OK]\n");
        return ret;
    }

    private Persistence startupPersistence(PrintStream log) {
        log.print("Starte Datenspeicherschicht...");
        Persistence ret = new DummyPersistence();
        log.print("[OK]\n");
        return ret;
        
    }

    private Service startupService(Persistence persistence,  PrintStream log) {
        log.print("Starte Dienstschicht...");
        Service ret =  new DummyService();
        log.print("[OK]\n");
        return ret;
    }

    private MainWindow startupGUI(Service service, PrintStream log) {
        log.print("Starte Darstellungsschicht...");
        MainWindow ret = new MainWindow(service, log);
        log.print("[OK]\n");
        return ret;
    }
    
}
